﻿using System;
using System.Collections.Generic;

/*
 * -- Pattern Responsibilities and Restrictions --
 * Definition: An object that acts as a Gateway (466) to a single record in a data source. There is one instance per row.
 *
 * 
 * Data Container:- 
 * REQUIRED: 1 database table should be mapped to one data container class.
 * REQUIRED: Data container names should be identical
 * 
 * Data Container Fields:-
 * REQUIRED: 1 database table column should be mapped to one field of the corresponding data container class
 * REQUIRED: No extra fields are allowed on any side.
 * REQUIRED: Field names should be identical
 * REQUIRED: No foreign key mapping to database fields
 * REQUIRED: No computation can be implemented on fields (i.e. derived fields) in the class
 * OPTIONAL ??: No validation logic (i.e. email/phone format etc) on data fields
 * 
 * CRUD Method :-
 * REQUIRED: Data container and CRUD methods are placed in same class
 * RECOMMENDED: Insert/Update method type: instance
 * RECOMMENDED: Insert/Update method parameter - no parameter is needed
 * RECOMMENDED: Delete/Get method type: static methods if in same class. Instance methods if in seperate class (for testability).
 * RECOMMENDED: Delete/Get method parameter: By Id etc
 * 
 * Business Logic :-
 * REQUIRED: No Computational logic (non-field level) can be included
 * REQUIRED: No transactional/workflow logic can be included
 * 
*/

/*
 * Database Schema:
 * 
        CREATE TABLE [Employee](
        	[EmployeeId] [int] NOT NULL,
        	[Name] [nvarchar](50)  NULL,
        	[Email] [nvarchar](50) NULL,
        	[MonthlySalary] [money] NULL,
        	[CompanyId] [int] NULL,
         CONSTRAINT [PK_Employee] PRIMARY KEY
        	(
        		[EmployeeId]
        	)
        )

 * 
 */
namespace RowDataGatewaySample
{
    public class EmployeeRowDataGateway
    {
        //every field is identical to the correspodning database table field
        public int EmployeeId { get; set; }
        public string Name { get; set; }
        public string Email { get; set; } 
        public double MonthlySalary { get; set; }
        public int CompanyId { get; set; }

        public EmployeeRowDataGateway() { }

        //by design principle/cohesion, insert/update methods should be instance method
        public void Insert() { throw new NotImplementedException(); }
        public void Update() { throw new NotImplementedException(); }

        //by design principle/cohesion, delete/read methods should be instance method
        //we can move this static methods to another class, if we need instance method (for testability purpose etc)
        public static void Delete(int EmployeeId) { throw new NotImplementedException(); }
        public static EmployeeRowDataGateway GetById(int EmployeeId) { throw new NotImplementedException(); }
        public static IList<EmployeeRowDataGateway> GetByCompanyId(int companyId) { throw new NotImplementedException(); }
    }
}
